﻿<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="./layui/css/layui.css" media="all">
</head>
<body>
    <!--出入库单打印-->
    <div class="stock-table" id="main">
        <div class="stock-item" v-for="(item,index) in stockList">
            <div class="box">
                <h3>出库单</h3>

                <table width="100%" border="0" class="layui-table" cellpadding="0">
                    <tr>
                        <td colspan="2" style="width:25mm;padding:1.5mm 0.5mm;white-space:nowrap;">出库单编号：</td>
                        <td colspan="3" style="width:60mm">{{item.code}}</td>
                        <td colspan="2" style="width:25mm">任务号</td>
                        <td colspan="3" style="width:60mm">{{item.taskcode}}</td>
                    </tr>
                    <tr>
                        <td colspan="2" style="padding:1.5mm 0.5mm">装备号：</td>
                        <td colspan="3">{{item.equipment}}</td>
                        <td colspan="2">装备名称：</td>
                        <td colspan="3">{{item.equipmentname}}</td>
                    </tr>
                    <tr>
                        <td colspan="2" style="padding:1.5mm 0.5mm">申领人：</td>
                        <td colspan="3">{{item.user_name}}</td>
                        <td colspan="2">申领部门：</td>
                        <td colspan="3">{{item.depname}}</td>
                    </tr>
                    <tr>
                        <td colspan="2" style="padding:1.5mm 0.5mm">申领日期：</td>
                        <td colspan="3">{{item.applicadate}}</td>
                        <td colspan="2">用途：</td>
                        <td colspan="3">{{item.useforway}}</td>
                    </tr>
                    <tr>
                        <td colspan="2" style="padding:1.5mm 0.5mm;white-space:nowrap;">部组件信息：</td>
                        <td colspan="8"><b> {{item.lvortuan}}</b>旅/团 <b>{{item.ying}}</b> 营 ，型号： <b>{{item.mode}}</b> 编号：<b>{{item.code2}}</b>  </td>
                    </tr>
                    <tr>
                        <td colspan="2" style="padding:1.5mm 0.5mm;white-space:nowrap;">备注：</td>
                        <td colspan="8"> {{item.remark}} </td>
                    </tr>
                    <tr>
                        <td style="width:35px;text-align:center">序号</td>
                        <td colspan="2" style="text-align:center;width:125px;">名称</td>
                        <td style="text-align:center;width:185px;">规格</td>
                        <td style="text-align:center;width:85px;">批次号</td>
                        <td style="text-align:center;width:35px;">单位</td>
                        <td style="text-align:center;width:65px;">数量</td>
                        <td style="text-align:center;width:65px;">单价</td>
                        <td style="width:80px;text-align:center">金额</td>
                        <td style="text-align:center;width:65px;">说明</td>
                    </tr>
                    <tr v-for="(jtem,index) in item.sublist">
                        <td style="width:35px;text-align:center">{{jtem.xh}}</td>
                        <td colspan="2" style="text-align:center;word-break: break-all;">{{jtem.name}}</td>
                        <td style="text-align:center;word-break: break-all;">{{jtem.model}}</td>
                        <td style="text-align:center">{{jtem.batchnumber}}</td>
                        <td style="text-align:center">{{jtem.unit}}</td>
                        <td style="text-align:center">{{jtem.quantity}}</td>
                        <td style="text-align:center">{{jtem.unitprice}}</td>
                        <td style="text-align:center">{{jtem.sumprice}}</td>
                        <td style="text-align:center">{{jtem.remark}}</td>
                    </tr>
                    <tr>
                        <td colspan="5" style="text-align:center">合计</td>
                        <td>&nbsp;</td>
                        <td style="text-align:center">{{item.nums}}</td>
                        <td style="text-align:center">{{item.unitprices}}</td>
                        <td style="text-align:center">{{item.sumprices}}</td>
                        <td>&nbsp;</td>
                    </tr>
                </table>
                <div class="stock-foot">
                    <p>{{item.details}}</p>
                </div>
                <div class="stock-foot">
                    <span style="width:30%">部门主管：{{item.部门主管审批}}</span>
                    <span style="width:30%">装保中心：{{item.装保中心}}</span>
                    <span style="width:30%" v-if="item.showA">管理保障：{{item.管理保障}}</span>
                    <span style="width:30%" v-if="item.showA">仓储中心：{{item.仓储中心主任}}</span>
                    <span style="width:30%" v-if="show1">生产主管：{{item.生产主管审批}}</span>
                    <span style="width:30%" v-if="show2">技术主管：{{item.技术主管审批}}</span>
                    <span style="width:30%" v-if="show3">质量主管：{{item.质量主管审批}}</span>
                    <span style="width:30%" v-if="show4">生产副厂长：{{item.生产副厂长}}</span>
                    <span style="width:30%" v-if="show5">厂长：{{item.厂长}}</span>
                    <span style="width:30%"></span>
                </div>
                <div class="stock-foot" style="height:25px">
                    <span style="width:30%"> </span>
                </div>
                <div class="stock-foot">
                    <span style="width:30%">领料人：</span>
                    <span style="width:30%">发料人：</span>
                    <span style="width:30%"></span>
                </div>
            </div>
        </div>
    </div>
    <link rel="stylesheet" href="/print/print.css?v=1.0.7" media="all">
    <script src="./layui/layui.js"></script>
    <script type="text/javascript" src="/print/jquery.min.js"></script>
    <script type="text/javascript" src="/print/qrcode.min.js"></script>
    <script type="text/javascript" src="/print/jquery-barcode.js"></script>
    <script src="js/vue.js"></script>
    <script>
        layui.use(['layer', 'table', 'element'], function () { //独立版的layer无需执行这一句
            var $ = layui.jquery, layer = layui.layer, table = layui.table, element = layui.element; //独立版的layer无需执行这一句
            var id = GetQueryValue("id");//0--前五个，1--物品标签，2--位置标签
            // id = "2D2E9DA2-3A50-4553-99F7-0D97448BFB81,4963DCFE-0631-4BB6-9A72-4EDCC9061D47,B4D6CE1D-9248-4538-B91D-51E73FF695C8";
            var main = new Vue({
                el: '#main',
                data: {
                    show1: false,
                    show2: false,
                    show3: false,
                    show4: false,
                    show5: false,
                    stockList: []
                },
                mounted: function () {
                    var self = this;
                    self.getStockList(id);

                },
                // 在 `methods` 对象中定义方法
                methods: {
                    getStockList: function (id) {
                        var self = this;
                        $.ajax({
                            url: '/print/data.ashx?oper=getStockOutList',
                            type: 'get',
                            async: true,
                            data: {
                                id: id
                            },
                            dataType: 'json'
                        }).then(function (res) {
                            console.log(res);
                            if (res.status == "1") {
                                var list = res.list;
                                var sublist = res.sublist;
                                if (list.length > 0) {
                                    self.setJson(list, sublist);
                                }
                                else {
                                    $(".stock-table").html("未查询到数据");
                                }
                            }
                            else {
                                layer.msg('系统错误');
                                return false;
                            }
                        }).fail(function (res) {
                            console.log('失败');
                            console.log(res.responseText);
                        })
                    },
                    setJson: function (list, sub) {
                        var self = this;
                        var dataList = [];

                        $.each(list, function (i, item) {
                            dataList.push(item);
                            console.log(!item.生产主管审批);
                            if (!item.生产主管审批) {
                                self.show1 = false;
                            } else {
                                self.show1 = true;
                            }
                            if (!item.技术主管审批) {
                                self.show2 = false;
                            } else {
                                self.show2 = true;
                            }
                            if (!item.质量主管审批) {
                                self.show3 = false;
                            } else {
                                self.show3 = true;
                            }
                            if (!item.生产副厂长) {
                                self.show4 = false;
                            } else {
                                self.show4 = true;
                            }
                            if (!item.厂长) {
                                self.show5 = false;
                            } else {
                                self.show5 = true;
                            }
                            if (!item.装保中心) {
                                dataList[i].showA = false;
                            } else {
                                dataList[i].showA = true;
                            }
                            if (!item.管理保障) {
                                dataList[i].showB = false;
                            } else {
                                dataList[i].showB = true;
                            }
                            var _nums = 0;
                            var _unitprices = 0;
                            var _sumprices = 0;
                            dataList[i].sublist = [];
                            $.each(sub, function (j, jtem) {
                                if (item.eid_stockout_id == jtem.eid_stockout_id) {
                                    if (jtem.quantity.length > 0) {
                                        _nums += parseFloat(jtem.quantity);
                                    }
                                    if (jtem.unitprice.length > 0) {
                                        _unitprices += parseFloat(jtem.unitprice);
                                    }
                                    if (jtem.sumprice.length > 0) {
                                        _sumprices += parseFloat(jtem.sumprice);
                                    }
                                    var _temp = jtem;
                                    var reg1 = new RegExp("：", "g");
                                    var reg2 = new RegExp("，", "g");
                                    var reg3 = new RegExp("【", "g");
                                    var reg4 = new RegExp("】", "g");
                                    var reg5 = new RegExp("〖", "g");
                                    var reg6 = new RegExp("〗", "g");
                                    var reg7 = new RegExp("&&&", "g");
                                    var reg8 = new RegExp("%%%", "g");
                                    var reg9 = new RegExp("@@@", "g");
                                    var name = jtem.name, model = jtem.model;

                                    name = name.replace(reg1, ":");
                                    name = name.replace(reg2, ",");
                                    name = name.replace(reg3, "{");
                                    name = name.replace(reg4, "}");
                                    name = name.replace(reg5, "[");
                                    name = name.replace(reg6, "]");
                                    name = name.replace(reg7, "/");
                                    name = name.replace(reg8, "\\");
                                    name = name.replace(reg9, "'");

                                    model = model.replace(reg1, ":");
                                    model = model.replace(reg2, ",");
                                    model = model.replace(reg3, "{");
                                    model = model.replace(reg4, "}");
                                    model = model.replace(reg5, "[");
                                    model = model.replace(reg6, "]");
                                    model = model.replace(reg7, "/");
                                    model = model.replace(reg8, "\\");
                                    model = model.replace(reg9, "'");
                                    _temp.name = name;
                                    _temp.model = model;
                                    dataList[i].sublist.push(_temp);
                                }
                            })

                            dataList[i].nums = _nums.toFixed(3);
                            dataList[i].unitprices = _unitprices.toFixed(3);
                            dataList[i].sumprices = _sumprices.toFixed(3);
                        })
                        console.log(dataList);
                        self.stockList = dataList;
                        setTimeout(function () {
                            window.print();
                        }, 2500)
                    }
                }
            })
            function GetQueryValue(queryName) {
                var reg = new RegExp("(^|&)" + queryName + "=([^&]*)(&|$)", "i");
                var r = window.location.search.substr(1).match(reg);
                if (r != null) {
                    return decodeURI(r[2]);
                } else {
                    return null;
                }
            }
        })
    </script>
</body>
</html>
